package com.chap17.completablefuture;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * <p>
 * <code>Demo13</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-05-10 14:09
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
@Slf4j
public class Demo13 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> cf = CompletableFuture.supplyAsync(() -> {
            int num = new Random().nextInt(10);
            log.debug("第一阶段：" + num);
            return num;
        }).thenRun(() -> log.debug("执行"));

        log.debug("最终结果：{}",cf.get());

    }
}
